local Class = require('lua.lang.Class')
local InputStream = require('lua.io.InputStream')

--- @class DataInputStream : InputStream
--- @field is InputStream
local DataInputStream = Class {
	__extends = InputStream
}

--- @param is InputStream
--- @return DataInputStream
function DataInputStream:new(is)
	--- @type DataInputStream
	local o = {}
	o.is = is
	return setmetatable(o, DataInputStream)
end

--- @return number
function DataInputStream:read()
	return self.is:read()
end

--- @param b number[]
--- @param off number
--- @param len number
--- @return void
function DataInputStream:readFully(b, off, len)
	for i = off, off + len - 1 do
		b[i] = self:read()
	end
end

--- @return number
function DataInputStream:readByte()
	return self:read() % 256
end

--- @return void
function DataInputStream:close()
	self.is:close()
	self.is = nil
end

return DataInputStream